package cn.tedu.medicalmanagementsystem.escort.pojo.vo;

public enum Gender {
    MALE("male", "男"),
    FEMALE("female", "女"),
    UNKNOWN("unknown", "未知");

    private final String code;
    private final String description;

    Gender(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 安全转换方法，处理null或无效值
     */
    public static Gender fromString(String genderStr) {
        if (genderStr == null || genderStr.trim().isEmpty()) {
            return UNKNOWN;
        }

        for (Gender gender : Gender.values()) {
            if (gender.code.equalsIgnoreCase(genderStr)) {
                return gender;
            }
        }

        return UNKNOWN;
    }
}